    var dataTable;
    
    var SELECTORS = {
        QUICK_SEARCH: "#btnQuickSearch",
        QUICK_SEARCH_INPUT: "#quickSearch",
        ADVANCE_SEARCH: "#advSearchSubmit",
        ADVANCE_SEARCH_ICON: "#btnAdvSearch",
        ADVANCE_SEARCH_PANEL: "#advSearchPanel",
        TABLE: "#logTable"
    };
    
    $(document).ready(function () {
        $('.panel-default .datetimepicker-default').datetimepicker();
        getLogList();
    });

    //低级查询按钮
    $(SELECTORS.QUICK_SEARCH).click(function () {
    	/*if ($("#quickSearch").val()=="") {
            window.top.window.showModalAlert("请输入检索条件。");
            return;
        }*/
    	getLogList();
    });

    //高级查询按钮
    $(SELECTORS.ADVANCE_SEARCH).click(function () {
    	/*if ($("#bizId").val()=="" && $("#tag").val()=="" && $("#user").val()=="" && $("#operation").val()=="" && $("#operTimeStart").val()=="" && $("#operTimeEnd").val()=="") {
            window.top.window.showModalAlert("请至少输入一个检索条件。");
            return;
        }*/
    	getLogList();
    });

    //高级查询隐藏
    $(SELECTORS.ADVANCE_SEARCH_ICON).click(function (event) {
        $(SELECTORS.ADVANCE_SEARCH_PANEL).toggle();
        $(SELECTORS.QUICK_SEARCH).toggle();
        $(this).children("i:eq(0)").toggleClass("fa-angle-double-down fa-angle-double-up");
        event.stopPropagation();
    });

    // 搜索框的回车事件
    $(SELECTORS.QUICK_SEARCH_INPUT).keydown(function(e){
        if(e.keyCode==13 && $(SELECTORS.QUICK_SEARCH).is(":visible")){
            $(SELECTORS.QUICK_SEARCH).click();
        }
    });
    
    function getLogList(){
        if (dataTable!=null && dataTable != undefined && ""!=dataTable){
        	dataTable.draw();
            return;
        }

        dataTable = $(SELECTORS.TABLE).DataTable({
            "processing": true,
            "serverSide": true,
            "lengthMenu": [[10, 25, 50], [10, 25, 50]],
            "dom": '<"bottom"rtflp>',
            "searching": false,
            //"scrollX" : "100%",
            //"scrollXInner" : "110%",
            //"scrollY" : "410px",
            "scrollCollapse": false,
            "pagingType": "full_numbers",
            "deferRender": true,
            "ajax": {
                "traditional": true,
                "url": "/log/search.action",
                "dataFilter": function(data) {
                    var json = jQuery.parseJSON(data);
                    json.recordsTotal = json.recordsTotal;
                    json.recordsFiltered = json.recordsFiltered;
                    return JSON.stringify(json);
                },
                "data": function (data) {
                    var sort = [];
                    for (var i = 0; i < data.order.length; i++) {
                        var order = data.order[i];
                        sort.push(data.columns[order.column].data + "," + order.dir);
                    }

                    var conditions = {
                        page: Math.floor(data.start / data.length),
                        size: data.length,
                        sort: sort
                    };

                    if ($("#advSearchPanel").is(":hidden")) {
                        return $.extend(conditions, {
                            quickSearch: true,
                            keyword: encodeURI($(SELECTORS.QUICK_SEARCH_INPUT).val())
                        });
                    } else {
                        // 高级查询条件
                        return $.extend(conditions, {
                        	quickSearch: false,
                            bizId: encodeURI($('#bizId').val()),
                            tag: encodeURI($('#tag').val()),
                            user: encodeURI($('#user').val()),
                            operation: encodeURI($('#operation').val()),
                            operTimeStart: encodeURI($('#operTimeStart').val()),
                            operTimeEnd: encodeURI($('#operTimeEnd').val())
                        });
                    }
                }
            },
            "tableTools": {
                "sRowSelect": "bootstrap"
            },
            "columns": [
            	{ "data": "operTime" },
                { "data": "bizId" },
                { "data": "tag" },
                { "data": "user" },
                { "data": "operation" },
                { "data": "detail" }
            ],
            "columnDefs": [
                { "orderable":true, className:"truncate-text log-column-detail", "targets":[0] },
                { "orderable":true, className:"truncate-text log-column-detail", "targets":[1] },
                { "orderable":true, className:"truncate-text log-column-detail", "targets":[2] },
                { "orderable":true, className:"truncate-text log-column-detail", "targets":[3] },
                { "orderable":true, className:"truncate-text log-column-detail", "targets":[4] },
                { "orderable":true, className:"truncate-text log-column-detail", "targets":[5] }
            ],
            "order": [[ 0, "desc" ]]
        });

        $(SELECTORS.TABLE).tooltip({
            selector: ".log-column-detail",
            container: "body",
            title: function() {
                if ($(this)[0].scrollWidth > $(this).outerWidth()) {
                    return $(this).text();
                }
            }
        });
        
    }
